cmake_minimum_required(VERSION 3.8)
project(mbot_app VERSION 0.1 LANGUAGES CXX)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(std_msgs REQUIRED)

find_package(Qt6 REQUIRED COMPONENTS Widgets LinguistTools)

set(TS_FILES src/mbot-app_zh_CN.ts)

include_directories(
    ${CMAKE_SOURCE_DIR}/include/app
    ${CMAKE_SOURCE_DIR}/include/app/node
    ${CMAKE_SOURCE_DIR}/include/app/widgets
)

set(PROJECT_SOURCES
    src/main.cpp
    src/mainwindow.cpp
    src/mainwindow.ui
    src/node/node.cpp
    src/widgets/directionCtl.cpp
    src/widgets/configCtl.cpp
    include/app/mainwindow.h
    include/app/node/node.h
    include/app/widgets/directionCtl.h
    include/app/widgets/configCtl.h
    ${TS_FILES}
)


add_executable(app
    # MANUAL_FINALIZATION
    ${PROJECT_SOURCES}
)

# Define target properties for Android with Qt 6 as:
#    set_property(TARGET mbot-app APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
#                 ${CMAKE_CURRENT_SOURCE_DIR}/android)
# For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation

# qt_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})


target_include_directories(app PUBLIC
  $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
  $<INSTALL_INTERFACE:include/${PROJECT_NAME}>)
target_compile_features(app PUBLIC c_std_99 cxx_std_17)  # Require C99 and C++17

# ros依赖
ament_target_dependencies(
  app
  rclcpp
  std_msgs
)
# 外部非ros依赖
target_link_libraries(app Qt6::Widgets)

install(TARGETS
  app
  DESTINATION lib/${PROJECT_NAME})

install(DIRECTORY
  DESTINATION share/${PROJECT_NAME}/
)

if(BUILD_TESTING)
  find_package(ament_lint_auto REQUIRED)
  # the following line skips the linter which checks for copyrights
  # comment the line when a copyright and license is added to all source files
  set(ament_cmake_copyright_FOUND TRUE)
  # the following line skips cpplint (only works in a git repo)
  # comment the line when this package is in a git repo and when
  # a copyright and license is added to all source files
  set(ament_cmake_cpplint_FOUND TRUE)
  ament_lint_auto_find_test_dependencies()
endif()

ament_package()
